
* Data Sharing with APJPA

use APJPA_datashare, clear
********************************************************************************
***** // DV Distribution // ****************************************************
********************************************************************************

twoway ///
kdensity PSM, lcolor(black) lpattern(solid) lwidth(*2) ///
xsc(range(-5 2)) xlabel(-5(.5)2) ///
xti("") yti("Kernel Density") ti("Public Service Motivation", size(medium)) name(dv, replace) ///
legend(order(1 "Full Sample" 2 "Police" 3 "Non-Police")) legend(position(9) ring(0)) ///
|| kdensity PSM, lcolor(gs10) lpattern(solid), if police == 1 ///
|| kdensity PSM, lcolor(gs10) lpattern(dash), if police == 0
graph save apjparr_dv, replace

* PSM distribution Treatment vs Control groups, in full sample 

twoway ///
kdensity PSM, lcolor(black) lpattern(solid) lwidth(*1.5) ///
xsc(range(-5 2)) xlabel(-5(.5)2) ///
xti("") yti("Kernel Density") ti("Public Service Motivation", size(medium)) name(dv_tnc, replace) ///
legend(order(1 "Positive Prime" 2 "Negative Prime" 3 "Control")) legend(position(9) ring(0)), if best == 1 ///
|| kdensity PSM, lcolor(black) lpattern(dash) lwidth(*1.5), if worst == 1 ///
|| kdensity PSM, lcolor(black) lpattern(dot) lwidth(*1.5), if cntrl == 1
graph save apjparr_dv_tnc, replace

********************************************************************************
***** // Main Analysis // ******************************************************
********************************************************************************

global c 	"i.female i.blk age poli i.educ public_yrs"

* Combined Sample
eststo combine: reg PSM i.best i.worst SDO $c, r

* Police Sample
eststo police: reg PSM i.best i.worst SDO $c, r, if police == 1

* Non-Police Sample
eststo nonpolice: reg PSM i.best i.worst SDO $c, r, if police == 0

esttab combine police nonpolice using threesamples.csv, replace ///
b se nobase onecell nogaps compress star(+ .1 * .05 ** .01 *** .001) ///
mti("combined" "police" "nonpolice")

********************************************************************************
***** // Post Hoc Power Analysis // ********************************************
********************************************************************************

* Combined sample
oneway PSM treatment, tab
power oneway 0 0.22 0.21, n1(162) n2(145) n3(149)

* Police sample
oneway PSM treatment, tab,  if police ==1
power oneway 0 0.33 0.085, n1(52) n2(36) n3(49)

* Non-Police sample
oneway PSM treatment, tab,  if police ==0
power oneway 0 0.194 0.259, n1(110) n2(109) n3(100)

********************************************************************************
***** // CFA // ****************************************************************
********************************************************************************

sem (APS1 APS2 APS3 APS4 CPV1 CPV2 CPV3 CPV4 COM1 COM2 COM3 COM4 SS1 SS2 SS3 SS4 <- Psm), ///
nocapslatent latent(Psm) method(ml) standardized 
condisc

sem (APSfactor CPVfactor COMfactor SSfactor <- Psm), ///
nocapslatent latent(Psm) method(ml) standardized 
condisc

sem (APS1 APS2 APS3 APS4<-Aps)(CPV1 CPV2 CPV3 CPV4<-Cpv)(COM1 COM2 COM3 COM4<-Com)(SS1 SS2 SS3 SS4<-Ss), ///
nocapslatent latent(Aps Cpv Com Ss) method(ml) standardized 
condisc

********************************************************************************
***** // MIMIC // **************************************************************
********************************************************************************

sem (Psm->APS1 APS2 APS3 APS4 CPV1 CPV2 CPV3 CPV4 COM1 COM2 COM3 COM4 SS1 SS2 SS3 SS4) ///
(Psm<-best worst police), ///
nocapslatent latent(Psm) method(ml) standardized nolog
estat eqgof
estat gof, stats(all) 

sem (Psm->APS1 APS2 APS3 APS4 CPV1 CPV2 CPV3 CPV4 COM1 COM2 COM3 COM4 SS1 SS2 SS3 SS4) ///
(Psm<-best worst police female blk age poli educ public_yrs SDO), ///
nocapslatent latent(Psm) method(ml) standardized nolog
estat eqgof
estat gof, stats(all) 

sem (Psm->APSfactor CPVfactor COMfactor SSfactor) ///
(Psm<-best worst police female blk age poli educ public_yrs SDO), ///
nocapslatent latent(Psm) method(ml) standardized nolog
estat eqgof
estat gof, stats(all) 

* police sample
sem (Psm->APS1 APS2 APS3 APS4 CPV1 CPV2 CPV3 CPV4 COM1 COM2 COM3 COM4 SS1 SS2 SS3 SS4) ///
(Psm<-best worst female blk age poli educ public_yrs SDO), ///
nocapslatent latent(Psm) method(ml) standardized nolog, if police == 1
estat eqgof
estat gof, stats(all) 

* non-police sample
sem (Psm->APS1 APS2 APS3 APS4 CPV1 CPV2 CPV3 CPV4 COM1 COM2 COM3 COM4 SS1 SS2 SS3 SS4) ///
(Psm<-best worst female blk age poli educ public_yrs SDO), ///
nocapslatent latent(Psm) method(ml) standardized nolog, if police == 0
estat eqgof
estat gof, stats(all) 

********************************************************************************
***** // LABELS // **************************************************************
********************************************************************************




tab treatment
label de treatment 0 "Control Group (No Recall)", modify
label de treatment 1 "Positive Recall", modify
label de treatment 2 "Negative Recall", modify
label values treatment treatment
 
tab best
label de best 1 "Positive Recall", modify
label de best 0 "Negative Recall/No Recall", modify
label values best best
 
tab worst
label de worst 1 "Negative Recall", modify
label de worst 0 "Positive Recall/No Recall", modify
label values worst worst
 
tab cntrl
label de cntrl 1 "No Recall", modify
label de cntrl 0 "Positive/Negative Recall", modify
label values cntrl cntrl
 
tab police
label de police 0 "Non-Police", modify
label de police 1 "Police", modify
label values police police
 
tab blk
label de blk 0 "Non-Black Subject", modify
label de blk 1 "Black Subject", modify
label values blk blk
 
tab female
label de female 0 "Male Subject", modify
label de female 1 "Female Subject", modify
label values female female



